import {request} from '../utils/request.js';
// 文章

/**
 * // 获取文章分类
 * @param url 路径
 */
export const getPostClass = ()=>{
	return request("GET","/post/class");
}

/**
 * 指定分类下的文章列表分页
 * @param current 当前第几页
 * @param classId 文章分类 
 */
export const getPostListPage = (current,classId)=>{
	return request("GET",`/post/postclass/${classId}/post/${current}`,{},{authorization:true})
}

/**
 * 获取文章详情
 * @param id 文章id
 */
export const getPostDetail = (id)=>{
	return request("GET",`/post/get/${id}/post`)
	
}

/**
 * 添加文章
 * @param id 文章id
 * 
 */
export const addPostApi = (data)=>{
	return request("POST",`/post/add/topic`,data,{authorization:true,checktoken:true})
}
/**
 * 搜索文章
 * 
 */
export const searchPostApi = (current,keyword)=>{
	return request("GET",`/post/search/${current}/page?keyword=${keyword}`,{},{authorization:true})
}
/**
 * 根据话题分类获取文章
 * 
 */
export const getPostByTopicApi = (topicId,current)=>{
	return request("GET",`/post/topic/${topicId}/post/${current}`,{},{authorization:true})
}
/**
 * 根据用户id获取文章
 * 
 */
export const getPostByUserIdApi = (userId,current)=>{
	return request("GET",`/post/user/${userId}/post/${current}`,{},{authorization:true,checktoken:true})
}

/**
 * 点赞/踩
 * 
 */
export const setPostZanApi = (postId,type)=>{
	return request("POST",`/post/support/add?postId=${postId}&type=${type}`,{},{authorization:true,checktoken:true})
}